<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="theme/Header.jsp" %>
<script type="text/javascript" src="js/con001edit.js" ></script>
<script type="text/javascript">
    $().ready(function() {
        $('#line').val('${data.lineId}');
        if($('#line').val() == "04" ||
            $('#line').val() == "06") {
            $('#enterStation').show();
            $('#dEnterStation').text('ด่านเข้า :');
            $('#dExitStation').text('ด่านออก :');
            $('#card').show();
            $('#ckCard').show();
            $('#dCard').text('ค่าปรับ IC CARD :');
        } else {
            $('#enterStation').hide();
            $('#dEnterStation').text('');
            $('#dExitStation').text('ด่าน :');
            $('#ckCard').hide();
            $('#dCard').text('');
        }

        $('#exitStation').val('${data.uapExitStation}');
        $('#enterStation').val('${data.uapEnterStation}');

        var uapDateTime = "${data.uapDate}";
        var date = uapDateTime.split(" ");
        var time = date[1].split(":");

        $('#uapDate').val(date[0]);
        $('#hour').val(time[0]);
        $('#minute').val(time[1]);
        $('#carType').val('${data.carTypeId}');
        $('#color').val('${data.colorId}');
        $('#brand').val('${data.brandId}');
        $('#plate').val('${data.plateNo}');
        $('#province').val('${data.provinceId}');
        $('#pay').val(parseInt('${data.pay}',10));
        $('#rate').val(parseInt('${data.rate}',10));
        $('#card').val(parseInt('${data.icCard}', 10));

        var card = $('#card').val(),
        pay = '${data.pay}',
        rate = '${data.rate}',
        result;

        if(card == 0) {
            card = "0";
        }

        result = (parseInt(card, 10) + parseInt(rate, 10)) - parseInt(pay, 10);
        $('#result').val(result);
        //$('#emp1').val('${data.emp1}');

    });
</script>

<div id="site-root">
    <div>
        <a href="CON001">[CON001- ยืนยันรถพลการทั่วไป]</a> [แก้ไข]
    </div>
</div>

<c:choose>
    <c:when test="${data.status == 'D' || data.status == 'R'}">
        <div id="button-bar">
            <fieldset >
                <div class="buttons">
                    <button class="positive" id="save">
                        <img  src="theme/images/icons/save.gif" alt="" width="16" height="16"/>บันทึกข้อมูล
                    </button>
                </div>
            </fieldset>
        </div>
    </c:when>
    <c:otherwise>
        <div class="info-box">สถานะไม่สามารถแก้ไข</div>
    </c:otherwise>
</c:choose>

<div id="source-data">
    <fieldset style="background: #FFF">
        <legend>รายละเอียดการบันทึกข้อมูล</legend>

        <form action="CON001Edit" id="frm_con001edit" method="post">
            <input type="hidden" id="p" name="p" value="${p}" />
            <input type="hidden" id="fUapDate" name="fUapDate" value="${fUapDate}" />
            <input type="hidden" id="fToUapDate" name="fToUapDate" value="${fToUapDate}" />
            <input type="hidden" id="fPlate" name="fPlate" value="${fPlate}" />
            <input type="hidden" id="fStation" name="fStation" value="${fStation}" />
            <input type="hidden" id="fStation2" name="fStation2" value="${fStation2}" />
            <input type="hidden" id="fUstatus" name="fUstatus" value="${fUstatus}" />
            <table width="100%" cellpadding="1">
                <tr>
                    <td width="150px" align="right">สายทาง : </td>
                    <td width="350px">
                        <select id="line" name="line" ${elementR} tabindex="1" >
                            <option value="" selected>เลือกสายทาง</option>
                            <c:forEach items="${lineList}" var="l" varStatus="i">
                                <option value="${l.lineId}">${l.lineId} : ${l.lineName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td width="150px" align="right">จำนวนเงินที่ชำระ :</td>
                    <td>
                        <input type="text" name="pay" id="pay" ${elementR} tabindex="12"/>
                    </td>
                </tr>
                <tr>
                    <td align="right"><div id="dExitStation">ด่าน : </div> </td>
                    <td>
                        <select id="exitStation" name="exitStation" ${elementR} tabindex="2">
                            <option value="" selected>เลือกด่าน</option>
                            <c:forEach items="${exitStationList}" var="s" varStatus="i">
                                <option value="${s.stationId}">${s.stationId} : ${s.stationName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td align="right">อัตราค่าผ่านทาง :</td>
                    <td>
                        <input id="rate" name="rate" ${elementR} readonly />
                    </td>
                </tr>
                <tr>
                    <td align="right"><div id="dEnterStation"></div> </td>
                    <td>
                        <select id="enterStation" name="enterStation" ${elementR} tabindex="3" >
                            <option value="" selected>เลือกด่าน</option>
                            <c:forEach items="${enterStationList}" var="s" varStatus="i">
                                <option value="${s.stationId}">${s.stationId} : ${s.stationName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td align="right"><div id="dCard"></div> </td>
                    <td>
                        <input type="checkbox" name="ckCard" id="ckCard" />
                        <input type="hidden" name="card" id="card" tabindex="13" /> &nbsp;
                    </td>
                </tr>
                <tr>
                    <td align="right">วันที่พลการ : </td>
                    <td>
                        <input type="text" name="uapDate" id="uapDate" readonly="" ${elementR} tabindex="4" value="${now}"/>
                        <a href="#"><img src="theme/images/icons/calendar_icon.gif"
                                         border="0" width="18" height="18"
                                         onclick="return showCalendar('uapDate', '%d/%m/%Y');"/></a>

                    </td>
                    <td align="right">พนักงานเก็บเงิน :</td>
                    <td>
                        <input type="text" name="emp1" id="emp1" ${elementN} tabindex="14" />
                        <input type="hidden" id="emp1a" name="emp1a" />
                        ช่องทาง
                        <input type="text" name="len" id="len" size="2" ${elementN} tabindex="15" />
                    </td>
                </tr>
                <tr>
                    <td align="right">เวลา : </td>
                    <td>
                        <!--
                        <input type="text" name="hour" id="hour" size="2" maxlength="2"
                               class="require" tabindex="5"/> :
                        <input type="text" name="minute" id="minute" size="2" maxlength="2" class="require" tabindex="6" />
                        -->
                        <select name="hour" id="hour" ${elementR} tabindex="5">
                            <option value="" selected></option>
                            <option value="00">00</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                        </select>:
                        <select name="minute" id="minute" ${elementR} tabindex="6">
                            <option value="" selected></option>
                            <option value="00">00</option>
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                            <option value="25">25</option>
                            <option value="26">26</option>
                            <option value="27">27</option>
                            <option value="28">28</option>
                            <option value="29">29</option>
                            <option value="30">30</option>
                            <option value="31">31</option>
                            <option value="32">32</option>
                            <option value="33">33</option>
                            <option value="34">34</option>
                            <option value="35">35</option>
                            <option value="36">36</option>
                            <option value="37">37</option>
                            <option value="38">38</option>
                            <option value="39">39</option>
                            <option value="40">40</option>
                            <option value="41">41</option>
                            <option value="42">42</option>
                            <option value="43">43</option>
                            <option value="44">44</option>
                            <option value="45">45</option>
                            <option value="46">46</option>
                            <option value="47">47</option>
                            <option value="48">48</option>
                            <option value="49">49</option>
                            <option value="50">50</option>
                            <option value="51">51</option>
                            <option value="52">52</option>
                            <option value="53">53</option>
                            <option value="54">54</option>
                            <option value="55">55</option>
                            <option value="56">56</option>
                            <option value="57">57</option>
                            <option value="58">58</option>
                            <option value="59">59</option>
                        </select>
                    </td>
                    <td align="right">พนักงานควบคุม :</td>
                    <td>
                        <input type="text" name="emp2" id="emp2" ${elementN} tabindex="16" />
                        <input type="hidden" name="emp2a" id="emp2a" />
                    </td>
                </tr>
                <tr>
                    <td align="right">ประเภทรถ : </td>
                    <td>
                        <select id="carType" name="carType" ${elementR} tabindex="7" >
                            <option value="" selected>เลือกประเภทรถ</option>
                            <c:forEach items="${carTypeList}" var="c" varStatus="i">
                                <option value="${c.carTypeId}">${c.carTypeName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td align="right">หัวหน้าพนักงาน :</td>
                    <td>
                        <input type="text" name="emp3" id="emp3" ${elementR} tabindex="17"
                               value="<%= (String) session.getAttribute("uap_user_desc")%>" />
                        <input type="hidden" id="emp3a" name="emp3a"
                               value="<%= (String) session.getAttribute("uap_user_id")%>" />

                    </td>
                </tr>
                <tr>
                    <td align="right">สีรถ : </td>
                    <td>
                        <select id="color" name="color" ${elementR} tabindex="8" >
                            <option value="" selected>เลือกสีรถ</option>
                            <c:forEach items="${colorList}" var="c" varStatus="i">
                                <option value="${c.colorId}">${c.colorName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td align="right">จำนวนเงินที่เรียกเก็บ :</td>
                    <td><input id="result" name="result" style="width:150px;border: 1px solid #000;
                               text-align: center;vertical-align: middle;
                               font-size: 30px;background: #000;color: green;" readonly /></td>
                </tr>
                <tr>
                    <td align="right">ยี่ห้อ : </td>
                    <td>
                        <select id="brand" name="brand" ${elementR} tabindex="9" >
                            <option value="" selected>เลือกยี่ห้อ</option>
                            <c:forEach items="${brandList}" var="b" varStatus="i">
                                <option value="${b.brandId}">${b.brandName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td align="right">เลขทะเบียน : </td>
                    <td><input type="text" name="plate" id="plate" ${elementR} tabindex="10" /></td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td align="right">จังหวัด : </td>
                    <td>
                        <select id="province" name="province" ${elementR} tabindex="11" >
                            <option value="" selected>เลือกจังหวัด</option>
                            <c:forEach items="${provinceList}" var="p" varStatus="i">
                                <option value="${p.provinceId}">${p.provinceName}</option>
                            </c:forEach>
                        </select>
                    </td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>

            </table>
        </form>
        <div class="tabber">

            <div class="tabbertab">
                <h2>ข้อมูลการบันทึกรายการ</h2>
                <fieldset style="background: #FFF">
                    <legend>รายละเอียดการบันทึก</legend>
                    <table width="100%" cellpadding="1">
                        <tr>
                            <td width="150px" align="right">วันที่บันทึกรายการ : </td>
                            <td width="350px">
                                <input type="text" name="uapCreate" id="uapCreate"
                                       value="${data.uapCreate}" class="lock" disabled/></td>
                            <td width="150px">&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr>
                            <td align="right">ผู้บันทึกรายการ : </td>
                            <td>
                                <input type="text" name="uapCreateBy" id="uapCreateBy"
                                       value="${data.uapCreateBy}" class="lock" disabled/></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                    </table>
                </fieldset>
            </div>
            <div class="tabbertab">
                <h2>ข้อมูลการแก้ไขรายการ</h2>
                <fieldset style="background: #FFF">
                    <legend>รายละเอียดการแก้ไข</legend>
                    <table border="0"  cellpadding="4" cellspacing="1">
                        <tr style="background: #3B5998;color: #FFF;font-size: 12px">
                            <th width="20px">&nbsp;</th>
                            <th width="200px">วันที่แก้ไข</th>
                            <th width="100px">ผู้ทำการแก้ไข</th>
                        </tr>
                        <c:choose>
                            <c:when test="${empty editLogList}">
                            </c:when>
                            <c:otherwise>

                                <c:forEach items="${editLogList}" var="result" varStatus="i">
                                    <tr id="${i.count}"
                                        onmouseover="over('${i.count}');"
                                        onmouseout="out('${i.count}','${i.count%2==0?"#FFFFFF":"#EEEFF4"}');"
                                        ondblclick="edit('','');"
                                        bgcolor="${i.count%2==0?"#FFFFFF":"#EEEFF4"}"
                                        style="font-size: 12px">
                                        <td>&nbsp;</td>
                                        <td align="center">${result.editDate}</td>
                                        <td align="center">${result.editBy}</td>

                                    </tr>
                                </c:forEach>
                            </c:otherwise>
                        </c:choose>
                    </table>
                </fieldset>
            </div>
            <div class="tabbertab">
                <h2>สถานะ</h2>
                <fieldset style="background: #FFF">
                    <legend>รายละเอียดสถานะ</legend>
                    <table width="100%" cellpadding="1">
                        <tr>
                            <td width="150px" align="right"><span style="background: #EEEFF4;">แผนกอนุมัติ : </span></td>
                            <td width="350px">
                                <c:choose>
                                    <c:when test="${data.approve1By != null}">
                                        <img  src="theme/images/icons/action_check.gif" alt="" width="16" height="16"/>
                                    </c:when>
                                    <c:otherwise>
                                        <img  src="theme/images/icons/action_delete.gif" alt="" width="16" height="16"/>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td width="150px"><span style="background: #EEEFF4;">ผู้บันทึก / วันที่บันทึก :</span></td>
                            <td>
                                <span style="background: yellow;">${data.approve1By}  ${data.approve1Date}</span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right"><span style="background: #EEEFF4;">ออกใบทวงหนี้ : </span></td>
                            <td>
                                <c:choose>
                                    <c:when test="${data.approve2By != null}">
                                        <img  src="theme/images/icons/action_check.gif" alt="" width="16" height="16"/>
                                    </c:when>
                                    <c:otherwise>
                                        <img  src="theme/images/icons/action_delete.gif" alt="" width="16" height="16"/>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td><span style="background: #EEEFF4;">ผู้บันทึก / วันที่บันทึก :</span></td>
                            <td>
                                <span style="background: yellow;">${data.approve2By}  ${data.approve2Date}</span>
                            </td>
                        </tr>

                        <tr>
                            <td align="right"><span style="background: #EEEFF4;">ชำระเงิน : </span></td>
                            <td>
                                <c:choose>
                                    <c:when test="${data.status == 'PY'}">
                                        <img  src="theme/images/icons/action_check.gif" alt="" width="16" height="16"/>
                                    </c:when>
                                    <c:otherwise>
                                        <img  src="theme/images/icons/action_delete.gif" alt="" width="16" height="16"/>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td><span style="background: #EEEFF4;">ผู้บันทึก / วันที่บันทึก :</span></td>
                            <td>&nbsp;</td>
                        </tr>

                    </table>
                </fieldset>
            </div>

        </div>
    </fieldset>
</div>
<script type="text/javascript">
    emp1("emp1","#emp1a");
    emp2("emp2","#emp2a");
    emp3("emp3","#emp3a");

</script>
<%@include file="theme/Footer.jsp" %>
